<?php

namespace App\Api\V2\Controller\Notify;


use App\Http\Controllers\Controller;
use App\Services\PengYiPeng\ThridLiteService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class AliyunController extends Controller
{

    /*
    ISV_GATEWAY_URL?charset=GBK&biz_content=
    {
    "app_auth_token":"211203BB6e8df9252c9e179d9f4c94d57d510X00","app_id":"2014072300007148","auth_app_id":"2013072300101234","user_id":"2088100000034011"
    }
    &msg_method=alipay.open.auth.appauth.cancelled&utc_timestamp=1516797622752&version=1.1&sign_type=RSA2&notify_id=d275fec564e62af6bedbcee73f3f05fi5x&app_id=2013121700999429&sign=I+Y/lvqYUEEc10EPdpntRhFIQ==
    */
    //from 消息通知
    public function fromNotify(Request $request): string
    {
        $data = $request->all();
        Log::channel("notify")->info("fromNotify：" . date("Y-m-d H:i:s", time()), [
            "data" => $data
        ]);
        $method = $data["msg_method"];

        switch ($method) {
            case "alipay.open.auth.appauth.cancelled":
                //验证签名校验
                $service = new ThridLiteService();
                $result = $service->alipayOpenAuthAppauthCancelled($data);
                break;
        }

        return $result;
    }
}
